package Apaper;

import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Administrator implements Serializable {
    public void use()throws IOException {
        int contine = 0;
        int AA = 0;
        while (AA == 0) {

            Scanner scanner = new Scanner(System.in);
            System.out.println("是否确认？ 0.是  1.否");
            AA = scanner.nextInt();
            if (AA == 1) {
                break;
            }

            System.out.println("0.更改专家名称  1.设置论文数量与名称 ");
            contine = scanner.nextInt();
            switch (contine) {
                case 0:
                    System.out.println("请分别输入五位专家名称");
                    PaperReviewSystem system = new PaperReviewSystem();
                    Expert[] experts = new Expert[5];
                    String[] contents = new String[5];
                    for (int j = 0; j < 5; j++) {
                        //输入专家名字
                        String b = scanner.next();
                        experts[j] = new Expert(b);
                        try (FileOutputStream fileOut = new FileOutputStream("object" + j + ".ser");
                             ObjectOutputStream objectOut = new ObjectOutputStream(fileOut)) {
                            objectOut.writeObject(experts[j]);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                    System.out.println("专家名字已经输入成功！");
                    System.out.println("==========================");
                    break;
                case 1:
                    PaperReviewSystem system1 = new PaperReviewSystem();

                    System.out.println("请输入论文数量");
                    int i = scanner.nextInt();
                    //输入论文数量
                    List<Paper> objectList = new ArrayList<>();
                    Paper[] papers = new Paper[i];
                    System.out.println("请分别输入论文名字");
                    for (int k = 0; k < i; k++) {
                        //输入论文名字
                        String a = scanner.next();
                        objectList.add(new Paper(a));
                    }

                    try (FileOutputStream fileOut = new FileOutputStream("objects.ser");
                         ObjectOutputStream objectOut = new ObjectOutputStream(fileOut)) {
                        objectOut.writeObject(objectList);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    System.out.println("论文设置成功");
                    System.out.println("============================");
                    break;
            }
            int password = 0;
            System.out.println("登录专家账号：123  登录管理员账号：321");
            password = scanner.nextInt();
            if (password == 123) {
                new UseExpert().Use();
            }
            if (password == 321) {
                new Administrator().use();
            }
        }

    }

}


